package com.example.mapper;

import com.example.entity.Student;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;

/**
 * Create with Intellij idea
 * User:鲁智明
 * Date:2018/10/15
 * Time:9:52
 * @CacheConfig 配置缓存基本信息 cacheNames 缓存名称
 * @Cacheable   配置需要缓存的方法(该方法查询数据库完毕之后，存入到缓存中)
 */

@CacheConfig(cacheNames = "studentCache")
public interface StudentMapper {

    @Select("select * from student where id=#{id}")
    @Cacheable
    public Student findById(@Param("id") int id);
}
